import * as OpcUa from '../thirdparty/opcua-webapi';

const testUserName = 'user1';
const testUserPassword = 'password1';
const allowLocalServerDebugging = true; // false 使用官方 server 测试需要跨域

// 青岛办公室 Server： https://192.168.50.26:44430/opcua
// Public Server： https://webapi.opcfoundation.org/opcua
const defaultUrl = (allowLocalServerDebugging) ? window.htconfig.Custom.server : "https://webapi.opcfoundation.org/opcua";

export const configuration = new OpcUa.Configuration({
    basePath: defaultUrl,
    fetchApi: (url, init) => {
        if (init) {
            const authorization = {
                'Authorization': `Basic ${btoa(`${testUserName}:${testUserPassword}`)}`
            };
            init.headers = { ...init.headers, ...authorization };
        }
        return fetch(url, init);
    }
});
